import datetime
import pytz

import coin.exchange.base.kr_rest.native_public_client_base as npubcb

class GopaxNativePublicClient(npubcb.NativePublicClientBase):
  def __init__(self):
    npubcb.NativePublicClientBase.__init__(self, url="https://api.gopax.co.kr")
    self._valid_kline_period = [1, 5, 30, 1440] #in minutes

  def check_kline_period(self, kline_period):
    assert kline_period in self._valid_kline_period, \
      'Invalid kline period! %s' % kline_period

  def get_history_kline(self, symbol, kline_period, start_time, end_time):
    self.check_kline_period(kline_period)
    params = {'start': int(start_time.timestamp() * 10**3),
              'end': int(end_time.timestamp() * 10**3),
              'interval': kline_period,
              'limit': 1024}
    return self._get_as_json("trading-pairs/%s/candles" % symbol, params=params)

  def queryAll(self):
    raise NotImplementedError()
